﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

// 1.




// 各类接口的实现/使用：
// void push_back(char c)尾插
// append尾插一个字符串

void TestFind1()
{
	string s("Hello BaiLetian! Hello Qianye! ");
	cout << s << endl;

	string tmp;
	for (auto ch : s)
	{
		if (ch == ' ')
			tmp += "%%";// 追加一个字符串
		else
			tmp += ch;// 追加字符ch
	}
	cout << tmp << endl;
	// 也可以使用赋值：
	// s = tmp;
	s.swap(tmp);
	cout << s << endl;
}
// find_first_of
// find_last_of 

void teststring()
{
	string s("test.cpp.zip");
	size_t pos = s.rfind('.');// 查找.操作符，并返回它的pos下标
	string suffix = s.substr(pos);
	cout << suffix << endl;

	std::string str("Please replace the vowels in this sentence by asterisks.");
	std::cout << str << "\n";

	std::size_t found = str.find_last_not_of("abcdef");
	while (found != std::string::npos)
	{
		str[found] = '*';
		found = str.find_first_not_of("abcdef", found + 1);
	}

	std::cout << str << "\n";

	std::string str1("/usr/bin/man");
	std::string str2("D:\\");

}


void teststring2()
{
	string s1("hello ");
	string s2 = s1 + "world ";// string + 字符串
	cout << s2 << endl;
	string s3 = "world " + s1;// 字符串 + string，
	cout << s3 << endl;		  // 左操作数和右操作数不一样，交换了以后的结果不一样
}

// getline
//
//﻿#include <cstddef>
//#include <iostream>
//using namespace std;
//int main()
//{
//	string str;
//	getline(cin, str);
//	size_t pos = str.rfind(' ');
//	cout << str.size() - (pos + 1) << endl;
//	return 0;
//}
//// 64 位输出请用 printf("%lld")

